<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
    <!-- <script src="js/axios.js"></script> -->
    
</head>
<body>  
    <!-- 组件之间的通信 非父子组件通信：bus
    -->
    <div id="app">
        <com1 type="password" v-model="checkText"></com1>
        <com1 type="number" v-model="radioText"></com1>
        <button @click="showInfo">显示</button>
    </div>
    <script>
        Vue.component("com1",{
            template:`
                <div>
                    <input :type="type" :value="value" @input="handleInput" />
                </div>
            `,
            methods:{
                handleInput(event){
                    this.$emit("input",event.target.value);
                }
            },
            props : ["value","type"],
        })
        
        var app = new Vue({
            el: "#app",
            data: {
                checkText:"",
                radioText:0
            },
            methods: {
                showInfo(){
                    console.log(this.checkText,this.radioText);
                }
            }
        });
    </script>
</body>
</html>